* net/tramp.el (tramp-read-passwd): Cached passwords shall still be used.
authorMichael Albinus <michael.albinus@gmx.de>
Sun, 1 Feb 2009 10:46:42 +0000 (10:46 +0000)
committerMichael Albinus <michael.albinus@gmx.de>
Sun, 1 Feb 2009 10:46:42 +0000 (10:46 +0000)
lisp/net/tramp.el

index e222a01a273495c9af54f8e7bbde73e60da3df48..e2e603a6b0a7a211d6f34614e917701b45b70144 100644 (file)
@@ -3664,7 +3664,7 @@ the result will be a local, non-Tramp, filename."
                (buffer-substring (point) (tramp-compat-line-end-position)))))
          (setq localname (concat uname fname))))
       ;; There might be a double slash, for example when "~/"
-      ;; expands to "/". Remove this.
+      ;; expands to "/".  Remove this.
       (while (string-match "//" localname)
        (setq localname (replace-match "/" t t localname)))
       ;; No tilde characters in file name, do normal
@@ -7433,12 +7433,14 @@ Invokes `password-read' if available, `read-passwd' else."
              (funcall (symbol-function 'auth-source-user-or-password)
                       "password" tramp-current-host tramp-current-method))
         ;; Try the password cache.
-        (and (functionp 'password-read)
-             (tramp-get-connection-property proc "first-password-request" nil)
-             (let ((password (funcall (symbol-function 'password-read)
-                                      pw-prompt key)))
-               (funcall (symbol-function 'password-cache-add) key password)
-               password))
+        (when (functionp 'password-read)
+          (unless (tramp-get-connection-property
+                   proc "first-password-request" nil)
+            (funcall (symbol-function 'password-cache-remove) key))
+          (let ((password
+                 (funcall (symbol-function 'password-read) pw-prompt key)))
+            (funcall (symbol-function 'password-cache-add) key password)
+            password))
         ;; Else, get the password interactively.
         (read-passwd pw-prompt))
       (tramp-set-connection-property proc "first-password-request" nil))))